<!DOCTYPE html>
<html lang="zh-cn" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8"/>
    <title>新增权限</title>
    <link rel="stylesheet" th:href="@{/webjars/ztree/3.5.0/css/zTreeStyle/zTreeStyle.css}" type="text/css"/>

</head>
<body style="min-width: 400px;">
<div th:replace="/layout/css :: #css"></div>

<div class="container-fluid">
    <form id="createForm" method="post" class="form-horizontal modal-form">
        <input id="id" name="id" th:type="hidden" th:value="${tagModel.id}"/>
        <div class="form-group">
            <label for="name" class="col-sm-3 control-label">标签名</label>
            <input id="name" name="name" class="form-control" th:value="${tagModel.name}"/>
        </div>
        <div class="form-group">
            <label for="target" class="col-sm-3 control-label">作用域</label>
            <select id="target" name="target" class="form-control">
                <option value="1" th:selected="${tagModel.target==1}">店铺</option>
                <option value="2" th:selected="${tagModel.target==2}">商品</option>
                <option value="3" th:selected="${tagModel.target==3}">CMS文章</option>
                <option value="4" th:selected="${tagModel.target==4}">CMS专题</option>
                <option value="5" th:selected="${tagModel.target==5}">CMS栏目</option>
            </select>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">标签状态</label>
            <div class="col-sm-8">
                <div class="radio">
                    <label class="radio-inline">
                        <input type="radio" name="status" id="status_nomal" value="1"
                               th:checked="${tagModel.status==1}"/>
                        正常
                    </label>
                    <label class="radio-inline">
                        <input type="radio" name="status" id="status_disable" value="0"
                               th:checked="${tagModel.status==0}"/>
                        禁用
                    </label>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">是否前台展示</label>
            <div class="col-sm-8">
                <div class="radio">
                    <label class="radio-inline">
                        <input type="radio" name="isShow" id="show_nomal" value="1" th:checked="${tagModel.isShow==1}"/>
                        显示
                    </label>
                    <label class="radio-inline">
                        <input type="radio" name="isShow" id="show_disable" value="0"
                               th:checked="${tagModel.isShow==0}"/>
                        不显示
                    </label>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label for="icon" class="col-sm-3 control-label">标签图标</label>
            <input id="icon" name="icon" class="form-control" th:value="${tagModel.icon}"/>
            <!--<input type="file" id="icon">
            <p class="help-block">Example block-level help text here.</p>-->
        </div>
        <div class="form-group">
            <label for="icon_type" class="col-sm-3 control-label">图标类型</label>
            <select id="icon_type" name="icon_type" class="form-control">
                <option value="1" th:selected="${tagModel.icon_type==5}">CSS图标</option>
                <option value="2" th:selected="${tagModel.icon_type==5}">图片</option>
            </select>
        </div>
        <div class="form-group">
            <label for="click_target" class="col-sm-3 control-label">点击跳转链接</label>
            <input id="click_target" name="click_target" class="form-control" th:value="${tagModel.click_target}"/>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">是否设置有效期</label>
            <div class="col-sm-8">
                <div class="radio">
                    <label class="radio-inline">
                        <input type="radio" name="time_validity" id="time_validity_nomal" value="1"
                               th:checked="${tagModel.time_validity==1}"/>
                        设置有效期
                    </label>
                    <label class="radio-inline">
                        <input type="radio" name="time_validity" id="time_validity_disable" value="0"
                               th:checked="${tagModel.time_validity==0}"/>
                        不设置有效期
                    </label>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">有效期范围:</label>
            <div class="col-sm-8 input-group">
                <div class="input-group-addon">
                    <i class="fa fa-clock-o"></i>
                </div>
                <input type="text" name="time_line" class="form-control pull-right" id="reservationtime" th:value="${tagModel.time_line}"/>
            </div>
        </div>

        <br/>
        <button type="button" class="btn btn-primary btn-block" onclick="doCreate()">保 存</button>

    </form>

    <div id="menuContent" class="menuContent">
        <ul id="treeMenu" class="ztree" style="margin-top:0; width:250px;"></ul>
    </div>

</div>

<div th:replace="/layout/js :: #js"></div>
<script type="text/javascript" th:src="@{/js/modalPage.js}"></script>
<script type="text/javascript" th:src="@{/webjars/ztree/3.5.0/js/jquery.ztree.core-3.5.min.js}"></script>
<script type="text/javascript" th:src="@{/webjars/ztree/3.5.0/js/jquery.ztree.excheck-3.5.min.js}"></script>
<script type="text/javascript" th:src="@{/webjars/ztree/3.5.0/js/jquery.ztree.exedit-3.5.min.js}"></script>

<script th:inline="javascript">

    $(function () {
        $('#reservationtime').daterangepicker({timePicker: true, timePickerIncrement: 30, format: 'MM/DD/YYYY h:mm A'})
    })
    
    function doCreate() {
        $.ajax({
            type: 'post',
            url: '/tag/update',
            data: $('#createForm').serialize(),
            success: function (result) {
                if (result.status != 0) {
                    failHandler(result);
                } else {
                    successConfirm();
                    closeModal();
                }
            },
            error: errorHandler
        });
    }
</script>
</body>
</html>